# example6_24_3dplot.py
# coding=utf-8
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams["font.sans-serif"] = ["SimHei"]
# 用来正常显示负号
plt.rcParams["axes.unicode_minus"] = False
plt.rcParams["font.size"] = 15  # 改变默认字体大小

fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")  # 创建三维坐标轴

x = np.linspace(-2, 2, 100)
y = x**2
z = 2 * np.sin(x**2) + np.cos(y) + 1

ax.plot(x, y, z, label="三维折线图")
ax.legend()
plt.savefig("3dplot.png")
plt.show()
